home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////////////////////////
- //
- // uBrowser - a program that illustrates one way of embedding the
- // Mozilla Gecko (tm) Rendering Engine in an application, grabbing the
- // rendered output and displaying it on the surface of a 3D polygon as
- // texture in an OpenGL (tm) application.
- //
- // uBrowser is free software; you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation; either version 2 of the License, or
- // (at your option) any later version.
- //
- // uBrowser is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with uBrowser; if not, write to the Free Software
- // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- //
- // Original code: Copyright 2005 Linden Research Inc.
- // http://www.lindenlab.com
- //
- // Primary author and site maintainer: Callum Prentice (callum@ubrowser.com)
- //
- // See contributors.txt or http://ubrowser.com for a list of contributors
- // without whose generous donation of time and effort, this application
- // would not have been possible.
- //
- ////////////////////////////////////////////////////////////////////////////////
- #ifndef UBROWSER_H
- #define UBROWSER_H
-
- #include <string>
- #include <vector>
- #include <math.h>
-
- #include "GL/glut.h"
- #include "glui.h"
-
- #include "embeddedbrowser.h"
- #include "embeddedbrowserwindow.h"
-
- static void gluiCallbackWrapper( int controlIdIn );
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- class uBrowser :
- public embeddedBrowserWindowObserver
- {
- public:
- uBrowser();
- ~uBrowser();
-
- bool init( const char* arg0, int appWindowIn );
- bool reset();
- const std::string& getName() { return mName; };
- void reshape( int widthIn, int heightIn );
- void makeChrome();
- void windowPosToTexturePos( int winXIn, int winYIn, int& texXOut, int& texYOut );
- void resetView();
- void drawGeometry( int typeIn );
-
- void display();
- void idle();
- void keyboard( unsigned char keyIn, int xIn, int yIn );
- void passiveMouse( int xIn, int yIn );
- void mouseButton( int button, int state, int xIn, int yIn );
- void mouseMove( int xIn, int yIn );
-
- void setSize( int widthIn , int heightIn );
-
- void gluiCallback( int controlIdIn );
-
- virtual void onNavigateBegin( const EventType& eventIn );
- virtual void onNavigateComplete( const EventType& eventIn );
- virtual void onUpdateProgress( const EventType& eventIn );
- virtual void onStatusTextChange( const EventType& eventIn );
- virtual void onLocationChange( const EventType& eventIn );
-
- private:
- void* getNativeWindowHandle();
- void uBrowser::setFocusNativeWindow();
-
- std::string mName;
- int mAppWindow;
- int mWindowWidth;
- int mWindowHeight;
- int mTextureWidth;
- int mTextureHeight;
- int mBrowserWindowWidth;
- int mBrowserWindowHeight;
- float mTextureScaleX;
- float mTextureScaleY;
- float mViewportAspect;
- float mViewPos[ 3 ];
- float mViewRotation[ 16 ];
- unsigned char mPixelColorRB[ 3 ];
- unsigned char mPixelColorG[ 3 ];
- int mCurMouseX;
- int mCurMouseY;
- GLuint mRedBlueTexture;
- unsigned char mRedBlueTexturePixels[ 256 * 256 * 3 ];
- GLuint mGreenTexture;
- unsigned char mGreenTexturePixels[ 16 * 16 * 3 ];
- GLuint mAppTexture;
- unsigned char* mAppTexturePixels;
- int mCurObjType;
- int mSelBookmark;
- GLUI* mTopGLUIWindow;
- GLUI_Button* mNavBackButton;
- GLUI_Button* mNavStopButton;
- GLUI_Button* mNavForwardButton;
- GLUI* mTop2GLUIWindow;
- GLUI_EditText* mUrlEdit;
- GLUI_String mNavUrl;
- GLUI* mRightGLUIWindow;
- GLUI_Rotation* mViewRotationCtrl;
- GLUI_Translation* mViewScaleCtrl;
- GLUI_Translation* mViewTranslationCtrl;
- GLUI* mBottomGLUIWindow;
- GLUI_StaticText* mStatusText;
- GLUI_StaticText* mProgressText;
- const int mIdReset;
- const int mIdExit;
- const int mIdBookmarks;
- const int mIdTypeNull;
- const int mIdTypeFlat;
- const int mIdTypeBall;
- const int mIdTypeCube;
- const int mIdTypeFlag;
- const int mIdUrlEdit;
- const int mIdNavBack;
- const int mIdNavStop;
- const int mIdNavHome;
- const int mIdNavForward;
- const int mIdBrowserSmall;
- const int mIdBrowserMedium;
- const int mIdBrowserLarge;
- const int mFocusUrlEdit;
- const std::string mHomeUrl;
- std::vector< std::pair< std::string, std::string > > mBookmarks;
- embeddedBrowser* mEmbeddedBrowser;
- };
-
- #endif // UBROWSER_H